Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lodash cloneDeep to support arrays in omitPaths #557

Merged
merged 2 commits into from
Aug 30, 2020

Conversation

MiguelNazMor
Copy link
Contributor

… and unit test with the case.

(Thanks for sending a pull request! Please make sure you click the link above to view the contribution guidelines, then fill out the blanks below.)

What does this implement/fix? Explain your changes.

While working with the middleware I discovered that, when adding a path to omitPaths which is apart of an array ("response.users[0].email"), the field was deleted form the log but also from the response.

Using cloneDeep fixes this behaviour (unit test added).

Does this close any currently open issues?

Any relevant logs, error output, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?

Where has this been tested?

Node.js Versions:
--12.4--
Middy Versions:

AWS SDK Versions:

Todo list

[ X] Feature/Fix fully implemented
[ X] Added tests
[ NA] Updated relevant documentation
[ NA] Updated relevant examples

@MiguelNazMor MiguelNazMor changed the title Add loads cloneDeep to support arrays in omitPaths Add lodash cloneDeep to support arrays in omitPaths Aug 28, 2020
@@ -9,7 +10,8 @@ module.exports = (opts) => {
const { logger, omitPaths } = Object.assign({}, defaults, opts)

const omitAndLog = message => {
const redactedMessage = omit(message, omitPaths)
const messageClone = cloneDeep(message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test using JSON.parse(JSON.stringify(o)) instead. _.cloneDeep is notoriously slow in comparison, unless you're using the additional edge cases.

lodash/lodash#1984

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated and tested, thanks for your comment!

@willfarrell willfarrell merged commit 3625b1e into middyjs:master Aug 30, 2020
@atwoodjw atwoodjw mentioned this pull request Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants